#ifndef CHOOSEFRIENDDIALOG_H
#define CHOOSEFRIENDDIALOG_H

#include <QDialog>
#include <QWidget>
#include <QVBoxLayout>
#include <QCheckBox>
#include <QPushButton>
#include <QLabel>

////////////////////////
/// 选择好友窗口
///////////////////////

class ChooseFriendDialog : public QDialog
{
    Q_OBJECT
public:
    ChooseFriendDialog(QWidget* parent, const QString& userId);

    void initLeft(QHBoxLayout* layout);
    void initRight(QHBoxLayout* layout);
    void clickOkBtn();
    QList<QString> generateMemberList();
    void initData();

    void addFriend(const QString& userId,const QIcon& avatar, const QString& name, bool checked);
    void addSelectedFriend(const QString& userId,const QIcon& avatar, const QString& name);
    void deleteSelectedFriend(const QString& userId);



private:
    //保存左侧全部好友列表的QWidget
    QWidget* totalContainer;
    //保存右侧选择好友
    QWidget* selectedContainer;

    //选择窗口是点击哪个用户
    QString userId;
};


////////////////////////
/// 选择好友窗口中一个元素
///////////////////////

class ChooseFriendItem : public QWidget
{
    Q_OBJECT
public:
    ChooseFriendItem(ChooseFriendDialog* owner,const QString& userId, const QIcon& avatar, const QString& name, bool checked);
    void paintEvent(QPaintEvent* event)override;
    void enterEvent(QEnterEvent* event)override;
    void leaveEvent(QEvent* event)override;
    const QString& getUserId() const
    {
        return userId;
    }
    QCheckBox* getCheckBox()
    {
        return checkBox;
    }
private:
    bool isHover = false;
    QCheckBox* checkBox;
    QPushButton* avatarBtn;
    QLabel* nameLabel;
    ChooseFriendDialog* owner; // 记录哪个QWidget 持有了整个Item, 此处的Qwidget 应该是一个 chooseFriendDialog

    QString userId;            //记录当前 Item 对应的 userId是啥

};

#endif // CHOOSEFRIENDDIALOG_H
